package hcontroller

import (
	"encoding/json"

	"advertoper/controllers"
	"advertoper/errorcode"
	"advertoper/homepageinfo/hservice"
)

type ZJSeckillUserController struct {
	controllers.LoginedController
}

//"提醒我"功能
// @router /push/call [post]
func (p *ZJSeckillUserController) PushCallUser() {
	defer p.Output("PushCallUser")
	p.ForceHTTPS()

	body := p.Ctx.Input.RequestBody
	req := &hservice.PushCallUserReq{}
	if err := json.Unmarshal(body, req); err != nil {
		p.Resp["code"] = errorcode.EC_GL_INVALID_JSON_BODY
		p.Resp["msg"] = errorcode.Msg(errorcode.EC_GL_INVALID_JSON_BODY)
		return
	}
	plat := 1
	if p.Appkey == "cc0dec8c07444e9dadb75d41218c4fe4" {
		plat = 2
	}
	code, msg := hservice.GetZJSeckillUserService().PushCallUser(p.Userid, plat, req)
	p.Resp["code"] = code
	p.Resp["msg"] = msg
}

//查用户设置了秒杀提醒的秒杀id
// @router /call-seckill/query [get]
func (p *ZJSeckillUserController) CallSeckillQuery() {
	defer p.Output("CallSeckillQuery")
	p.ForceHTTPS()

	code, msg, seckillIds := hservice.GetZJSeckillUserService().CallSeckillQuery(p.Userid)
	p.Resp["code"] = code
	p.Resp["msg"] = msg
	p.Resp["seckill_ids"] = seckillIds
}
